﻿app.controller('HomeController', function ($scope, LoginFactory) {
    $scope.status = LoginFactory.status;
    $scope.user = {
        username : '', password : ''
    }
    $scope.userInfo = {};
    $scope.login = function () {
        LoginFactory.login($scope.user).then(function () {
            $scope.getUserInfo();
        });
    }
    $scope.logout = LoginFactory.logout;

    $scope.getUserInfo = function () {
        LoginFactory.getInfo().then(function (data) {
            $scope.userInfo = data;
        });
    }
    if ($scope.status.loggedin) $scope.getUserInfo();
})